package com.cvs.contorller;

import com.cvs.bean.Orders;
import com.cvs.bean.User;
import com.cvs.service.OrdersService;
import com.cvs.service.UserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class OrdersController {
    @Autowired
    private OrdersService ordersService;
    @Autowired
    private UserService userService;
    @RequestMapping("/myOrder")
    public String myOrder(int uid, Integer pageNum, Integer pageSize,Integer type, Model model){
        if (null==pageNum||null==pageSize){//避免空值异常情况
          pageNum=new Integer(1);
          pageSize=new Integer(3);
        }
     PageInfo<Orders> pageInfo= ordersService.findAll(uid,pageNum,pageSize,type);
     model.addAttribute("orders",pageInfo);
        User user=userService.findUserInfo(uid);
        model.addAttribute("user",user);//用户信息

        return "myOrder";
    }
}
